<?php
namespace Admin\Controller;
use Think\Controller;
class ContactUsController extends BaseController {
    public function index(){
        $this->login_verify();
        $case=M('addarticle');
        $casenewslist=$case->select();
        $this->assign("casenewslist",$casenewslist);
        // 获取用户名
       
        $this->display();
    }
/*内容图片上传*/ 
    public function addContent(){
    	$data['content']=$_POST['content'];
    	$data['title']=$_POST['title'];
    	$data['name']=$_POST['name'];
    	$data['time']=date("Y-m-d H:i:s");
        $data['name']=$_COOKIE['enrollusername'];
        $upload = new \Think\Upload();// 实例化上传类
        $upload->maxSize   =     2097152 ;// 设置附件上传大小
        $upload->exts      =     array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
        $upload->saveName = 'time';
        $upload->subName = 'article';
        $upload->rootPath  =     './Uploads/'; // 设置附件上传根目录
        $info   =   $upload->uploadOne($_FILES['imgurl']);
        if(!$info) {// 上传错误提示错误信息
            $this->error($upload->getError());
        }else{// 上传成功 获取上传文件信息
            $case=M('addarticle');
            $data['imgurl']='Uploads/'.$info['savepath'].$info['savename'];
            // var_dump($data);
            if($case->data($data)->add()){
                $this->success("上传成功",U('ContactUs/index'));
            }else{
                $this->error("上传失败");
            }
        }
    }
/*删除操作*/ 
    public function caseDel(){
        $id=I('get.id');
        $case=M('addarticle');
        if($case->where('id='.$id)->delete()){
                $this->success("删除成功",U('ContactUs/index'));
        }else{
                $this->error("删除失败");
        }
    }
}
